﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using ParserCore;

namespace TestParser
{
    public partial class ParserUnitTestTrle
    {
        [TestMethod]
        public void test_if_x_lt_3_then_x_eq_0_else_if_y_gt_6_y_eq_x_plus_3()
        { 
            var expression = "if (x<3), x=0; elseif (y>6), y=x+3;end";
            var parser = new ParsingEngine();
            Assert.AreEqual(parser.Parse(expression),
                new IfThenElseStatement(
                        new Call(
                            new Identifier("<"),
                            new Identifier("x"),
                            new Constant("3",Constant.CType.RealNumber)
                            ),
                            new AssignmentStatement(
                                new Expression[] { new Identifier("x") },
                                new Constant("0", Constant.CType.RealNumber) ),
                            new IfThenElseStatement(
                                new Call(
                                    new Identifier(">"),
                                    new Identifier("y"),
                                    new Constant("6", Constant.CType.RealNumber) ),
                                new AssignmentStatement(
                                    new Expression[] { new Identifier("y") },
                                        new Call(
                                        new Identifier("+"),
                                        new Identifier("x"),
                                        new Constant("3", Constant.CType.RealNumber)
                                    )),
                            new BlockStatement(new Statement[] {})
                            )
                        )
                    );
        }
    }
}
